﻿<%@ WebHandler Language="C#" Class="getVacation" %>

using System;
using System.Web;
using System.Data;
using Newtonsoft.Json;

public class getVacation : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        string pid = StringHelper.SafeSqlInput(context.Request.QueryString["pid"]);
        string type = StringHelper.SafeSqlInput(context.Request.QueryString["type"]);
        DBHelper db = new DBHelper();

        DataTable dt;

        string sql = "";
        if (type == "1")
        {
            sql = "select " + pid + " as relid,a.*,b.mc from ";
            sql += " (";
            sql += " select team,'U' as sign from   dict_Vacation_detail where relid=" + pid;
            sql += " union";
            sql += " select id as team,'I' as sign from [dbo].[dict_team] where id not in";
            sql += " (select team  from   dict_Vacation_detail where relid=" + pid + ")";
            sql += " ) a left outer join [dict_team] b on a.team=b.id order by a.team";
        }
        else if (type == "0")
        {
            sql = "select * from dict_vacation where id=" + pid;
        }
        dt = db.getList(sql);
        context.Response.ContentType = "application/json";
        context.Response.Write(JsonConvert.SerializeObject(dt));
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}